package com.lzw.breezeNovel.webApp.controller.comic;

import com.lzw.breezeNovel.common.result.Result;
import com.lzw.breezeNovel.webApp.service.comic.ComicCollectionService;
import com.lzw.breezeNovel.webApp.vo.comic.ComicVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.controller.comic
 * @date 2025/3/16
 * @description 漫画收藏表
 */
@RestController
@RequestMapping("/app/comic/collection")
@SuppressWarnings("all")
public class ComicCollectionController {

   /**
    * 注入service
    */
   @Autowired
   private ComicCollectionService comicCollectionService;

   /**
    * 收藏漫画
    */
   @RequestMapping("/add")
   public Result add(@RequestParam Integer comicId) {
      comicCollectionService.add(comicId);
      return Result.ok();
   }

   /**
    * 取消收藏
    */
   @RequestMapping("/cancel")
   public Result cancel(@RequestParam Integer comicId) {
      comicCollectionService.cancel(comicId);
      return Result.ok();
   }

   /**
    * 获取当前用户的所有的收藏
    */
   @RequestMapping("/list")
   public Result<List<ComicVo>> list() {
         List<ComicVo> comicVos = comicCollectionService.list();
         return Result.ok(comicVos);
   }

   /**
    * 删除当前用户的所有的收藏
    */
   @DeleteMapping("/delete")
   public Result delete(@RequestParam Integer comicId) {
      comicCollectionService.delete(comicId);
      return Result.ok();
   }

}
